<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
    <link rel="stylesheet" href="asset/bootstrap@5.3.0/css/bootstrap.min.css">
</head>
<body>
<!-- 导航条 -->
<nav class="navbar navbar-expand-lg bg-body-tertiary">
    <div class="container-fluid">
        <a class="navbar-brand" href="#">Navbar</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="#" >Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Link</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        Dropdown
                    </a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="#">Action</a></li>
                        <li><a class="dropdown-item" href="#">Another action</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="#">Something else here</a></li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a class="nav-link disabled">Disabled</a>
                </li>
                <li class="nav-item d-flex">
                    <input class="form-control me-2" type="search" placeholder="请输入关键字" aria-label="Search">
                    <button class="btn btn-outline-success" type="submit">Search</button>
                </li>
            </ul>
            <!--<div class="d-flex">
                <a class="nav-link px-3" href="#">登录</a>
                <a class="nav-link px-3" href="#">注册</a>
            </div>-->
        </div>
    </div>
</nav>
<!-- 导航条 -->

<h1>这是index页面</h1>

<!-- 表单 -->


<script src="asset/bootstrap@5.3.0/js/bootstrap.bundle.min.js"></script>
<script>
    let navbarSupportedContent=document.querySelector("#navbarSupportedContent");
    //从sessionStorage中获得数据
    let infoString=sessionStorage.getItem("info");
    let loginMsg=JSON.parse(infoString);
    let loginDom = `<div class="d-flex">
                <a class="nav-link px-3" href="#">登录</a>
                <a class="nav-link px-3" href="#">注册</a>
                </div>`;
    if(loginMsg) {
        loginDom = `<div class="d-flex">
                <a class="nav-link px-3" href="#">${loginMsg.user.displayName}</a>

                </div>`;
    }
    let subDom=document.createRange().createContextualFragment(loginDom);
    navbarSupportedContent.append(subDom)
</script>
</body>
</html>